home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
Mandlebrot
/
Mandlebrot Folder
/
Readme
< prev
Wrap
Text File
|
1990-05-09
|
4KB
|
83 lines
Mandelbrot in LightSpeed C
by Bruce Gladstone -- 5/90
This program was freely adapted from the MPW Pascal version in"On MacIntosh Programming: Advanced Techniques" by
Daniel K. Allen, published by Addison-Wesley (pp 87-100). It's an interesting example since it uses the event loop
differently from most MAC programs. The event loop is called from inside the main number crunching program. So it
illustrates how you would run compute intensive programs on the MAC and still keep some semblence of the MAC
interaction. Some of the changes to Daniel Allen's program (other than the conversion to C are:
1. I used 'sprintf' and 'CtoPstr' instead of 'Num2Str' for the data conversions used in the parameter
displays. There are some questions I still have about this. To safely set aside space for the string
to be converted I use a declaration of Str255 for the string. This does not match the declaration for
sprintf but it works if you turn off pointer checking (which I did). The questions are: What is the
proper way to call stdio routines if you are in a Mac application? Is Lightspeed 4.0 with the precomp-
iled ANSI libraries a step back from 3.0 whid according to <library notes of June 2, 1988> seems to
allow you to pick out sprintf without all the rest of stdio?
2. The 68881 version of the program has the 'Calcmandel' routine embedded as in-line code in
'Drawmandel' routine. This and the conversion to assembly language with removal of some uneccessary
loads and stores results in a small speedup. Bigger improvements come from running under the finder
and removing any Inits that monitor operation ala Screensavers. Removing a screensaver INIT and
running w/o multifinder led to a 30% speedup on a MAC II and IIci.
3. I broke the program up into six modules and a header file.
4. I used the more standard approach to creating menus by putting them into a separate resource file. I
did create the windows in the program so that the Mandel window could be the full screen size.
5. I changed the program slightly from the "successive approximation" Allen used for aesthetic reasons.
6. I use calls to GetCTable ( numColorBits )to get the default system CLUTs and
aColor = (**myColorHandle).ctTable[n].rgb and RGBForeColor ( &aColor ) to pick the color to plot.
I didn't include the projects because they increase the size of the download file quite a bit. The files to
included to make a non-68881 version of the code are:
AboutMandel.c
DrawMandel.c
Event.c
MacTraps
Mandelbrot.c
Menu.c
MenuUpdate.c
--------------------
ANSI /* in its own segment */
and... The Lightspeed C options are: The project type is:
MacsBug Symbols No Application
Profile No File Type APPL
68020 code No Creator ????
68881 code No Partition 384K
<Macheaders> No MF Attrs 0800
Require prototypes Yes
Check pointers Yes (except for MenuUpdate.c)
The files to included to make a 68881 version of the code are:
AboutMandel.c
DrawMandel881.c
Event.c
MacTraps
Mandelbrot.c
Menu.c
MenuUpdate.c
--------------------
ANSI-881 /* in its own segment */
and... The Lightspeed C options are: The project type is:
MacsBug Symbols No Application
Profile No File Type APPL
68020 code Yes Creator ????
68881 code Yes Partition 384K
<Macheaders> No MF Attrs 0800
Require prototypes Yes
Check pointers Yes (except for MenuUpdate.c)
FINALLY A WARNING. This program can be an incredible time sink. The variations are innumerable and all tempting.
Avoid the temptation to fiddle endlessly. I am publishing this so that I can concentrate on more productive activities.
I think I have extracted all the 'learning about programming the Mac' from this example that I can.